package com.chance.cc.crawler.development.command.job.domain.xhs.notes;

import com.chance.cc.crawler.core.downloader.proxy.Proxy;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.command.job.CrawlerJobCommand;
import org.apache.commons.lang3.StringUtils;

import static com.chance.cc.crawler.core.CrawlerEnum.CrawlerRequestType.*;

/**
 * @author lt
 * @version 1.0
 * @date 2021-06-17 10:26:26
 * @email okprog@sina.com
 */
public class XhsCommonCrawlerSchedulerJob {

    public static final String domain = "xhs";
    public static final String metaServiceIp = "192.168.1.215";
    public static final int metaServicePort = 9599;
    public static final String metaServiceHttpPrefix = "http://"+metaServiceIp+":"+metaServicePort;

    public static final String userAgentUrl = "https://fake-useragent.herokuapp.com/browsers/0.1.11";

    public static final String kafkaTopic = "";
    public static final String tmpKafkaTopic = "tmp_social_media";

    public static CrawlerJobCommand metaServiceCommand = new CrawlerJobCommand(metaServiceIp,metaServicePort);

    public static Proxy proxy = new Proxy();
    static {
        //代理配置
        //H5168QRFNIU3804D
        //5F6B3610BB719FAA
        proxy.setHost("http-dyn.abuyun.com");
        proxy.setPort(9020);
        proxy.setUsername("HL89Q19E86E2987D");
        proxy.setPassword("71F33D94CE5F7BF2");
    }
    public static CrawlerRequestRecord getKwRecord(String metaSite, String site){
        //keyword record
        return CrawlerRequestRecord.builder()
                .startPageRequest(StringUtils.joinWith("-",domain, site),turnPageItem)
                .httpUrl("http://"+metaServiceIp+":"+metaServicePort+"/v1/meta/"+domain+"/keys?site=" + metaSite)
                .requestLabelTag(supportSource)
                .requestLabelTag(internalDownload)
                .build();
    }

    public static CrawlerRequestRecord getAuthRecord( String site){
        return CrawlerRequestRecord.builder()
                .startPageRequest(domain + "_" + site + "_oauth_infos", turnPageItem)
                .httpUrl("http://"+metaServiceIp+":"+metaServicePort+"/crawler/oauth/api/v1/"+domain+"/userOauthInfos")
                .requestLabelTag(supportSource)
                .requestLabelTag(internalDownload)
                .build();
    }

}
